﻿@using LKVService
@{
    ViewBag.Title = "MainCategory";
    Layout = "~/Views/Shared/_LayoutAdmin.cshtml";
}
@model LKVMLMLib.DanhMucTinTuc
<div id="wrapper">
    <div class="row">
        <div class="col-lg-12">
            <div class="panel-body">
                <div class="row" style="padding-left:2%;">
                    <span style="color:orangered">@ViewBag.Error</span>
                    @if (Model.ID != 0)
                    {
                        using (Html.BeginForm("EditCategory", "News", FormMethod.Post, new { @class = "login-form form-horizontal" }))
                        {
                            @Html.HiddenFor(m => m.ID, new { @Id = "txtID" })
                            @Html.HiddenFor(m => m.Status)
                            <table cellpadding="0" cellspacing="0" border="0">
                                <tr>
                                    <td><label style="vertical-align:bottom;line-height:2px;margin-right:5px;"> Tên danh mục:</label></td>
                                    <td>@Html.TextBoxFor(m => m.Name, new { @Class = "form-control", @Style = "width:200px" })</td>
                                    <td><button type="submit" class="btn btn-default" style="margin-left:5px;margin-right:5px;">Lưu</button><button type="reset" class="btn btn-default">Reset</button></td>
                                </tr>
                            </table>
                            @*<div class="row" style="display:table;">
                                    @Html.HiddenFor(m => m.ID, new { @Id = "txtID" })
                                    @Html.HiddenFor(m => m.Status)
                                    <div class="form-group">
                                        <label>Tên danh mục:</label>
                                        @Html.TextBoxFor(m => m.Name, new { @Class = "form-control", @Style = "width:200px" })
                                        <button type="submit" class="btn btn-default">Lưu</button>
                                        <button type="reset" class="btn btn-default">Reset</button>
                                    </div>
                                </div>*@
                        }
                    }
                    else
                    {
                        using (Html.BeginForm("AddCategory", "News", FormMethod.Post, new { @class = "login-form form-horizontal" }))
                        {
                            @Html.HiddenFor(m => m.ID, new { @Id = "txtID" })
                            <table cellpadding="0" cellspacing="0" border="0">
                                <tr>
                                    <td><label style="vertical-align:bottom;line-height:2px;margin-right:5px;"> Tên danh mục:</label></td>
                                    <td>@Html.TextBoxFor(m => m.Name, new { @Class = "form-control", @Style = "width:200px" })</td>
                                    <td><button type="submit" class="btn btn-default" style="margin-left:5px;margin-right:5px;">Thêm</button><button type="reset" class="btn btn-default">Reset</button></td>
                                </tr>
                            </table>
                        }
                    }
                </div>
            </div>
        </div>
    </div>
</div>
<div class="row">
    <div class="col-lg-12">
        <div class="panel-body">
            <div class="dataTable_wrapper">              
                <table class="table table-striped table-bordered table-hover" id="dataTables-example">
                    <thead>
                        <tr>
                            <th>STT</th>
                            <th>Tên Danh Mục</th>
                            <th>Tùy chọn</th>
                        </tr>
                    </thead>
                    <tbody>
                        @{int j = 0;}
                        @foreach (var item in ViewBag.DanhMuc)
                        {
                            j++;
                            <tr>
                                <td>@j</td>
                                <td>@item.Name</td>
                                <td><a href="@Url.Action("MainCategory", "News", new { Id = item.ID })">Xem</a> &nbsp;<a href="@Url.Action("DeleteCategory", "News", new { Id = item.ID })">Xóa</a></td>
                            </tr>
                        }
                    </tbody>
                </table>
                <a href="@Url.Action("MainCategory", "News", new { Id = 0, err = "" })" style="float:left !important;" class="btn_submit btn btn-default">Thêm mới</a>
            </div>
            <!-- /.table-responsive -->
        </div>
        <!-- /.panel-body -->
    </div>
</div>